package com.k12.user.controller;

import com.k12.user.model.entity.SysAreaDistricts;
import com.k12.user.service.SysAreaDistrictsService;

import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;
import java.util.List;
/**
 * 区县代码库(SysAreaDistricts)表控制层
 *
 * @author makejava
 * @since 2025-07-28 20:53:10
 */
@RestController
@RequestMapping("sysAreaDistricts")
public class SysAreaDistrictsController {
    /**
     * 服务对象
     */
    @Resource
    private SysAreaDistrictsService sysAreaDistrictsService;

    /**
     * 分页查询
     *
     * @param sysAreaDistricts 筛选条件
     * @param pageRequest      分页对象
     * @return 查询结果
     */
    @GetMapping("getAllDistricts")
    public List<SysAreaDistricts> queryByPage(SysAreaDistricts sysAreaDistricts) {
        return this.sysAreaDistrictsService.queryByPage(sysAreaDistricts);
    }

    /**
     * 通过主键查询单条数据
     *
     * @param id 主键
     * @return 单条数据
     */
    @GetMapping("getOneDistricts/{id}")
    public SysAreaDistricts queryById(@PathVariable("id") Integer id) {
        return this.sysAreaDistrictsService.queryById(id);
    }

    /**
     * 新增数据
     *
     * @param sysAreaDistricts 实体
     * @return 新增结果
     */
    @PostMapping("insertDistricts")
    public SysAreaDistricts add(SysAreaDistricts sysAreaDistricts) {
        return this.sysAreaDistrictsService.insert(sysAreaDistricts);
    }

    /**
     * 编辑数据
     *
     * @param sysAreaDistricts 实体
     * @return 编辑结果
     */
    @PostMapping("updateDistricts")
    public SysAreaDistricts edit(SysAreaDistricts sysAreaDistricts) {
        return this.sysAreaDistrictsService.update(sysAreaDistricts);
    }

    /**
     * 删除数据
     *
     * @param id 主键
     * @return 删除是否成功
     */
    @GetMapping("deleteDistricts")
    public Boolean deleteById(Integer id) {
        return this.sysAreaDistrictsService.deleteById(id);
    }

}

